package com.ciwong.epaper.modules.wordlist.util;

import android.app.Activity;
import android.content.Intent;

import com.ciwong.epaper.modules.me.ui.ErrorWorkActivity;
import com.ciwong.epaper.modules.wordlist.WordListReadActivity;
import com.ciwong.epaper.modules.wordlist.bean.PageListBean;
import com.ciwong.epaper.modules.wordlist.ui.WordBookWordDetailActivity;
import com.ciwong.epaper.modules.wordlist.ui.WorkBookActivity;
import com.ciwong.mobilelib.utils.BaseIntentFlag;
import com.ciwong.mobilelib.utils.BaseJumpManager;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;


/**
 * @date :2018/3/29
 * @author: loco
 * @description:跳转页面
 * @version:2.4
 */
public class WorkBookJumpManager extends BaseJumpManager {

    /**
     * 跳转到练习册
     *
     * @param goBackId
     * @param context
     */
    public static void jumpToWorkBookActivity(int goBackId, Activity context) {
        Intent intent = getBaseIntent(goBackId, context, WorkBookActivity.class);
        context.startActivity(intent);
    }

    /**
     * 跳转到错题本
     *
     * @param goBackId
     * @param context
     */
    public static void jumpToErrorWorkActivity(int goBackId, Activity context) {
        Intent intent = getBaseIntent(goBackId, context, ErrorWorkActivity.class);
        context.startActivity(intent);

    }

    /**
     * 跳转单词练习
     *
     * @param goBackId
     * @param context
     */
    public static void jumpToWordPracticeActivity(int goBackId, Activity context, LinkedList<PageListBean> linkList, int requestCode) {
        Intent intent = getBaseIntent(goBackId, context,
                WordListReadActivity.class);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_OBJ_LIST, linkList);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_REQUEST_CODE_FROM, requestCode);
        context.startActivityForResult(intent, requestCode);

    }

    /**
     * 跳转单词详情
     */
    public static void jumpToWordDetailActivity(int goBackId, Activity context, ArrayList<PageListBean> pageListBeans, int position, String scoreRange, int currentPage) {
        Intent intent = getBaseIntent(goBackId, context,
                WordBookWordDetailActivity.class);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_OBJ, pageListBeans);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_STR, scoreRange);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_CURRENT_PAGE, currentPage);
        context.startActivity(intent);

    }


    /**
     * 测试
     *
     * @param goBackId
     * @param context
     */
  /*  public static void jumpToWorkBookActivity(int goBackId, Activity context) {

        List<ResourceDetail>  listBigQuistion    = initData(context);
        List<Boolean>  listRecorder    =new ArrayList<>();
        for (int i=0;i<listBigQuistion.size();i++){
            listRecorder.add(false);
        }
        ResourceDetail  mResurceDetail =listBigQuistion.get(1);
        String mResourceName= "听说资源";
       int mBigQuesIndex=0;

        Intent intent = getBaseIntent(goBackId, context, AbstractShortConversationActivity.class);


//        intent.putExtra(BaseJumpManager.GO_BACK_ID, R.string.go_back);
        intent.putExtra(BaseJumpManager.INTENT_FLAG_SOURCE, true);
        intent.putExtra(INTENT_FLAG_STR, mResourceName);
        intent.putExtra(IntentFlag.INTENT_FLAG_ACTION, ListenSpeakUtil.LsMode.OWN_PRACTISE);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_OBJ, mResurceDetail);
        intent.putExtra(BaseIntentFlag.INTENT_FLAG_OBJ_LIST, (Serializable) listBigQuistion);
        intent.putExtra("BIG_QUESTION_INDEX", mBigQuesIndex);
        // TODO: 2018/5/3 添加集合被选中的Boolean
        intent.putExtra("IS_DO_RECORDS_LIST", (Serializable)listRecorder);

        context.startActivityForResult(intent,666);

    }
    private static List<ResourceDetail> initData(Activity context) {
         *//*获取到assets文件下的TExt.json文件的数据，并以输出流形式返回。*//*
        InputStream is = context.getClass().getClassLoader().getResourceAsStream("assets/" + "shortdialog.json");
        InputStreamReader streamReader = new InputStreamReader(is);



        BufferedReader reader = new BufferedReader(streamReader);
        String line;
        StringBuilder stringBuilder = new StringBuilder();
        try {
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }
            reader.close();
            reader.close();
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Gson gson = new Gson();
        ListenspeakExam listenspeakExam = gson.fromJson(stringBuilder.toString(), ListenspeakExam.class);
        List<ResourceDetail> items = listenspeakExam.getItems();
        ResourceDetail  mResourceDetail=listenspeakExam.getItems().get(0);
        return items;
    }
*/

}
